
#include "bird.h"

Bird::Bird(QWidget *parent)
    : QWidget{parent}
{
    //加载鸟图片资源
    for(int i=0;i<this->max;i++)
    {
        QString str=QString(":/Image/bird%1").arg(i+1);
        this->m_Bird_Pix.load(str);
    }

    //统一一下合适尺寸
    this->setFixedSize(this->m_Bird_Pix.width(),this->m_Bird_Pix.height());

    //创建定时器的对象
    this->timer=new QTimer(this);

    //监听定时器的信号来切图
    connect(timer,&QTimer::timeout,[=](){
        QString str=QString(":/Bird/bird%1").arg(this->min++);
        this->m_Bird_Pix.load(str);
        if(this->min>this->max)
        {
            this->min=1;
        }
    });

}

void Bird::running()
{
    //开始计时

    this->timer->start(50);
}
